package conf

import "runtime"

const DbDriverName = "mysql"
const Domain = "http://www.zhaobanzhilian.com"

var (
	MasterDbConfig       DbConfig
	UploadPrefix         Prefix
	MiniConfig           Mini
	WechatPayment        Payment
	OpenWechatAppConfig  OpenWechatApp
	PolymerizationConfig Polymerization
	ListDataConfig       ListConfig
)

type DbConfig struct {
	Host   string
	Port   int
	User   string
	Pwd    string
	DbName string
}

type Prefix struct {
	Front   string
	Backend string
}

type Mini struct {
	AppId     string // 微信小程序appid
	AppSecret string // 微信小程序appsecret
}

type Payment struct {
	MchId  string // 微信支付商户号
	ApiKey string // 微信支付ApiKey
}

type OpenWechatApp struct {
	AppId  string // 微信开放平台移动应用AppId
	Secret string // 微信开放平台移动应用AppSecret
}

type Polymerization struct {
	Key string
}

type ListConfig struct {
	PerPage int // 每页显示多少条数据
}

func init() {
	sysType := runtime.GOOS
	if sysType == "darwin" {
		MasterDbConfig = DbConfig{
			Host:   "127.0.0.1",
			Port:   3306,
			User:   "root",
			Pwd:    "2rNet29_.",
			DbName: "baokaobang",
		}

		UploadPrefix = Prefix{
			Front:   "/Users/kelvin/work/wk/baokaobangadmin/public",
			Backend: "/Users/kelvin/work/wk/baokaobangadmin",
		}
	} else if sysType == "windows" {
		MasterDbConfig = DbConfig{
			Host:   "127.0.0.1",
			Port:   3306,
			User:   "root",
			Pwd:    "123456",
			DbName: "baokaobang",
		}

		UploadPrefix = Prefix{
			Front:   "E:/projects/baokaobangadmin/public",
			Backend: "E:/GoProjects/baokaobang/",
		}
	} else if sysType == "linux" {
		MasterDbConfig = DbConfig{
			Host:   "172.16.0.7",
			Port:   3306,
			User:   "root",
			Pwd:    "abxy736$#",
			DbName: "baokaobang",
		}

		UploadPrefix = Prefix{
			Front:   "/var/www/statics",
			Backend: "/var/www/baokaobang",
		}
	}

	MiniConfig = Mini{
		AppId:     "wxda402238e6017288",
		AppSecret: "3c81ced1e7f603f3d2f237643ad72358",
	}

	WechatPayment = Payment{
		MchId:  "1565344471",
		ApiKey: "0b194c28636479c7e186a7f6cebffde7",
	}

	OpenWechatAppConfig = OpenWechatApp{
		AppId:  "wx9129cbcdd1c1d545",
		Secret: "14d5fd3169b2924d8f550c79af210317",
	}

	PolymerizationConfig = Polymerization{
		Key: "635ed4ca7e4e91b6445805e3a4e72150",
	}

	ListDataConfig = ListConfig{
		PerPage: 6,
	}
}
